using Digitalmes.Domain.Entities.Mes.Productions;

namespace Digitalmes.Application.Mes.Productions.WorkOrders.Queries;

/// <summary>
/// 工单查询命令。
/// </summary>
public sealed record GetWorkOrderListQuery : IRequest<IResult<List<ProdWorkOrderDto>>>;

internal sealed class GetWorkOrderListQueryHandler(IRepository<ProdWorkOrder> repo) : IRequestHandler<GetWorkOrderListQuery, IResult<List<ProdWorkOrderDto>>>
{
    public async Task<IResult<List<ProdWorkOrderDto>>> Handle(GetWorkOrderListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(cancellationToken);
        return Result.From(items.Adapt<List<ProdWorkOrderDto>>());
    }
}
